﻿using DLUProject.Data;
using DLUProject.Domain;
using DLUProject.Services;
using StructureMap;

/// <summary>
/// Summary description for StructmapInitialize
/// </summary>
public class StructmapInitialize
{
    public static IContainer Initialize()
    {
        ObjectFactory.Initialize(x =>
        {
            x.Scan(scan =>
            {
                scan.TheCallingAssembly();
                scan.WithDefaultConventions();
                scan.Assembly("DLUProject.Domain");
                scan.Assembly("DLUProject.Services");
            });
            // x.For<IExample>().Use<Example>();
            
            x.For<IServices<AccountGroup>>().Use<AccountGroupService>();
            x.For<IRepository<AccountGroup>>().Use<AccountDBRepository<AccountGroup>>();
            x.For<IServices<Account>>().Use<AccountService>();
            x.For<IRepository<Account>>().Use<AccountDBRepository<Account>>();
            x.For<IServices<GroupFunction>>().Use<GroupFunctionService>();
            x.For<IRepository<GroupFunction>>().Use<AccountDBRepository<GroupFunction>>();
            x.For<IServices<AccountLog>>().Use<AccountLogService>();
            x.For<IRepository<AccountLog>>().Use<AccountDBRepository<AccountLog>>();
           
            x.For<IRepository<Systems>>().Use<AccountDBRepository<Systems>>();
            x.For<IServices<Systems>>().Use<SystemsService>();

            x.For<IServices<WorkGroup>>().Use<WorkGroupService>();
            x.For<IRepository<WorkGroup>>().Use<AccountDBRepository<WorkGroup>>();
            x.For<IServices<AccountInGroup>>().Use<AccountInGroupService>();
            x.For<IRepository<AccountInGroup>>().Use<AccountDBRepository<AccountInGroup>>();
            x.For<IServices<Function>>().Use<FunctionService>();
            x.For<IRepository<Function>>().Use<AccountDBRepository<Function>>();
            x.For<IServices<Setting>>().Use<SettingService>();
            x.For<IRepository<Setting>>().Use<AccountDBRepository<Setting>>();


            x.For<IServices<SinhVien>>().Use<SinhVienService>();
            x.For<IRepository<SinhVien>>().Use<QuanLyKTXRepository<SinhVien>>();
            x.For<IServices<KhuNha>>().Use<KhuNhaService>();
            x.For<IRepository<KhuNha>>().Use<QuanLyKTXRepository<KhuNha>>();
            x.For<IServices<LoaiThietBi>>().Use<LoaiThietBiService>();
            x.For<IRepository<LoaiThietBi>>().Use<QuanLyKTXRepository<LoaiThietBi>>();
            x.For<IServices<LoaiDichVu>>().Use<LoaiDichVuService>();
            x.For<IRepository<LoaiDichVu>>().Use<QuanLyKTXRepository<LoaiDichVu>>();
            x.For<IServices<DienNuoc>>().Use<DienNuocService>();
            x.For<IRepository<DienNuoc>>().Use<QuanLyKTXRepository<DienNuoc>>();
            x.For<IServices<HoaDonSV>>().Use<HoaDonSVService>();
            x.For<IRepository<HoaDonSV>>().Use<QuanLyKTXRepository<HoaDonSV>>();
            x.For<IServices<Phong>>().Use<PhongService>();
            x.For<IRepository<Phong>>().Use<QuanLyKTXRepository<Phong>>();
            x.For<IServices<ChiTietHoaDonSV>>().Use<ChiTietHoaDonSVService>();
            x.For<IRepository<ChiTietHoaDonSV>>().Use<QuanLyKTXRepository<ChiTietHoaDonSV>>();
            x.For<IServices<HoaDonPhong>>().Use<HoaDonPhongService>();
            x.For<IRepository<HoaDonPhong>>().Use<QuanLyKTXRepository<HoaDonPhong>>();
            x.For<IServices<ChiTietHoaDonPhong>>().Use<ChiTietHoaDonPhongService>();
            x.For<IRepository<ChiTietHoaDonPhong>>().Use<QuanLyKTXRepository<ChiTietHoaDonPhong>>();
            x.For<IServices<Module>>().Use<ModuleService>();
            x.For<IRepository<Module>>().Use<QuanLyKTXRepository<Module>>();

            x.For<IServices<Khoa>>().Use<KhoaService>();
            x.For<IRepository<Khoa>>().Use<QuanLyKTXRepository<Khoa>>();
            
            x.For<IServices<Lop>>().Use<LopService>();
            x.For<IRepository<Lop>>().Use<QuanLyKTXRepository<Lop>>();

            x.For<IServices<ModuleInstance>>().Use<ModuleInstanceService>();
            x.For<IRepository<ModuleInstance>>().Use<QuanLyKTXRepository<ModuleInstance>>();
            x.For<IServices<ThietBi>>().Use<ThietBiService>();
            x.For<IRepository<ThietBi>>().Use<QuanLyKTXRepository<ThietBi>>();
            x.For<IServices<XepPhongSinhVien>>().Use<XepPhongSinhVienService>();
            x.For<IRepository<XepPhongSinhVien>>().Use<QuanLyKTXRepository<XepPhongSinhVien>>();
            x.For<IServices<ThongBao>>().Use<ThongBaoService>();
            x.For<IRepository<ThongBao>>().Use<QuanLyKTXRepository<ThongBao>>();
            x.For<IServices<DichVu>>().Use<DichVuService>();
            x.For<IRepository<DichVu>>().Use<QuanLyKTXRepository<DichVu>>();
            x.For<IRepository<Pages>>().Use<QuanLyKTXRepository<Pages>>();
            x.For<IServices<Pages>>().Use<PagesService>();

            x.For<IServices<TinTuc>>().Use<TinTucService>();
            x.For<IRepository<TinTuc>>().Use<QuanLyKTXRepository<TinTuc>>();
            x.For<IServices<DanhMucTinTuc>>().Use<DanhMucTinTucService>();
            x.For<IRepository<DanhMucTinTuc>>().Use<QuanLyKTXRepository<DanhMucTinTuc>>();

            x.SetAllProperties(y =>
            {
                // y.OfType<IService>();    

                y.OfType<IServices<AccountGroup>>();
                y.OfType<AccountGroupExtension>();
                y.OfType<IServices<Account>>();
                y.OfType<AccountExtension>();
                y.OfType<IServices<GroupFunction>>();
                y.OfType<GroupFunctionExtension>();
                y.OfType<IServices<AccountLog>>();
                y.OfType<AccountLogExtension>();
                y.OfType<IServices<Systems>>();
                y.OfType<SystemsExtension>();
                y.OfType<IServices<WorkGroup>>();
                y.OfType<WorkGroupExtension>();
                y.OfType<IServices<AccountInGroup>>();
                y.OfType<AccountInGroupExtension>();
                y.OfType<IServices<Function>>();
                y.OfType<FunctionExtension>();
                y.OfType<IServices<Setting>>();
                y.OfType<SettingExtension>();

                y.OfType<IServices<SinhVien>>();
                y.OfType<SinhVienExtension>();
                y.OfType<IServices<KhuNha>>();
                y.OfType<KhuNhaExtension>();
                y.OfType<IServices<LoaiThietBi>>();
                y.OfType<LoaiThietBiExtension>();
                y.OfType<IServices<LoaiDichVu>>();
                y.OfType<LoaiDichVuExtension>();
                y.OfType<IServices<DienNuoc>>();
                y.OfType<DienNuocExtension>();
                y.OfType<IServices<HoaDonSV>>();
                y.OfType<HoaDonSVExtension>();
                y.OfType<IServices<Phong>>();
                y.OfType<PhongExtension>();
                y.OfType<IServices<ChiTietHoaDonSV>>();
                y.OfType<ChiTietHoaDonSVExtension>();
                y.OfType<IServices<HoaDonPhong>>();
                y.OfType<HoaDonPhongExtension>();
                y.OfType<IServices<ChiTietHoaDonPhong>>();
                y.OfType<ChiTietHoaDonPhongExtension>();
                y.OfType<IServices<Module>>();
                y.OfType<ModuleExtension>();
                y.OfType<IServices<ModuleInstance>>();
                y.OfType<ModuleInstanceExtension>();
                y.OfType<IServices<ThietBi>>();
                y.OfType<ThietBiExtension>();
                y.OfType<IServices<XepPhongSinhVien>>();
                y.OfType<XepPhongSinhVienExtension>();
                y.OfType<IServices<ThongBao>>();
                y.OfType<ThongBaoExtension>();
                y.OfType<IServices<DichVu>>();
                y.OfType<DichVuExtension>();

                y.OfType<IServices<Pages>>();
                y.OfType<PagesExtension>();

                y.OfType<IServices<TinTuc>>();
                y.OfType<TinTucExtension>();
                y.OfType<IServices<DanhMucTinTuc>>();
                y.OfType<DanhMucTinTucExtension>();

                y.OfType<IServices<Khoa>>();
                y.OfType<KhoaExtension>();
                y.OfType<IServices<Lop>>();
                y.OfType<LopExtension>();
            });
        });
        return ObjectFactory.Container;
    }
}
